Skip to content

Add copy-to-clipboard button for scan_display_id#142

Open
saitejasviputta wants to merge 6 commits into
jpdevhub:mainfrom
saitejasviputta:add-copy-buttons
Open

Add copy-to-clipboard button for scan_display_id#142
saitejasviputta wants to merge 6 commits into
jpdevhub:mainfrom
saitejasviputta:add-copy-buttons

Conversation

@saitejasviputta

@saitejasviputta saitejasviputta commented Jun 27, 2026

Copy link
Copy Markdown

Description:
Added a clipboard icon next to scan_display_id in ResultsPage.

Closes #121

Changes:

  • Added Copy icon using lucide-react
  • Implemented clipboard copy using navigator.clipboard.writeText()
  • Added toast notification on success/failure
  • Improved UX for quickly copying Scan IDs

Testing:

  • Verified UI renders correctly
  • Click action triggers copy functionality

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a copy action for scan display IDs in the results history, including success/error toasts.
    • Added the ability to copy the public report URL from the Public Report page, including success/error toasts.
  • UI Updates

    • Simplified the Public Report controls by removing the previous share/copy link flow.
    • Added a dedicated “PUBLIC REPORT URL” section with a copy icon button.

@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

@saitejasviputta is attempting to deploy a commit to the karan3431's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

🎉 Thank you for your Pull Request! We're thrilled to have your contribution to FreshScan AI.

Before we review, please make sure you have:

  • Followed the CONTRIBUTING.md guidelines.
  • Ensured all automated CI checks (linting, tests) are passing.
  • Checked that your commit messages follow the Conventional Commits format.

A maintainer will review your code as soon as possible!

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5b815e8b-8dcc-4b2b-b0a8-b92c10867c06

📥 Commits

Reviewing files that changed from the base of the PR and between bdd2b88 and 4c980e9.

📒 Files selected for processing (2)
  • src/pages/PublicReport.tsx
  • src/pages/ResultsPage.tsx

📝 Walkthrough

Walkthrough

PublicReport and ResultsPage now add clipboard-copy actions with toast feedback. The public report page copies the current report URL, and the results history list copies each scan display ID with a new Copy icon.

Changes

Clipboard copy UI

Layer / File(s) Summary
Public report URL copy
src/pages/PublicReport.tsx
Adds Copy and toast imports, removes the prior copied state, introduces copyReportUrl(), and renders a PUBLIC REPORT URL section with a copy control and simplified print/save actions.
Scan ID copy
src/pages/ResultsPage.tsx
Adds Copy and toast imports, introduces copyScanId(scanId), and replaces plain history text with a copy control next to each scan_display_id.

Estimated code review effort: 2 (Simple) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding a copy-to-clipboard button for scan_display_id.
Linked Issues check ✅ Passed The PR adds clipboard copy controls for both scan_display_id and the public report URL, using writeText and success toasts.
Out of Scope Changes check ✅ Passed The changes stay focused on copy-to-clipboard UI and behavior for the two requested values.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/ResultsPage.tsx`:
- Line 65: The catch block in ResultsPage’s error handling currently declares an
unused `error` binding, which will trip ESLint. Update the `catch` clause to
either remove the parameter entirely or use it meaningfully in the ResultsPage
logic (for example, logging or telemetry) so the `catch` around this code no
longer contains an unused variable.
- Around line 157-166: The Copy control inside ResultsPage’s card Link is
currently an SVG click target, so it triggers navigation to /analysis and isn’t
keyboard accessible. Replace the Copy icon usage with a real button in the
ResultsPage card markup, and in its click handler call preventDefault() and
stopPropagation() before invoking copyScanId. Keep the existing copyScanId
behavior, but make sure the interactive element is the button rather than the
icon component itself.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 49d1bd0b-ba22-40e2-ba77-9b3325099ac1

📥 Commits

Reviewing files that changed from the base of the PR and between f4ec5c5 and aa63b52.

📒 Files selected for processing (1)
  • src/pages/ResultsPage.tsx

Comment thread src/pages/ResultsPage.tsx Outdated
Comment thread src/pages/ResultsPage.tsx Outdated
@jpdevhub

Copy link
Copy Markdown
Owner

Great start! The scan_display_id copy button is working perfectly. However, the issue also requires a copy button next to the public report URL (/report/:id). Could you add that as well before we merge?

@saitejasviputta

saitejasviputta commented Jun 29, 2026

Copy link
Copy Markdown
Author

Hello @jpdevhub ,
Thanks for the review! I've added the copy button next to the public report URL as requested and also fixed the lint issue. I have also addressed the accessibility suggestion by wrapping the copy icon in a button. The PR has been updated.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/PublicReport.tsx`:
- Around line 31-34: The copy-to-clipboard logic in PublicReport’s copyReportUrl
should use the canonical report route instead of window.location.href, since the
current URL may include query/hash state. Update copyReportUrl to build the
share link from window.location.origin and the report id so it always copies the
/report/:id URL, and make sure any other report URL copy/share paths referenced
in the same component use the same canonical construction.
- Around line 103-107: The Copy icon in PublicReport lacks keyboard-accessible
button semantics because the click handler is attached directly to the icon
component. Update the PublicReport component so the copy action is triggered by
a real button wrapping the Copy icon, and keep the icon decorative inside it.
Preserve the existing copyReportUrl behavior and styling by moving the click
handler, title/label, and cursor/hover affordances to the button element.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 37fa1dae-4f57-4160-88d7-3c6a4d89e938

📥 Commits

Reviewing files that changed from the base of the PR and between aa63b52 and 894c6d9.

📒 Files selected for processing (2)
  • src/pages/PublicReport.tsx
  • src/pages/ResultsPage.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/ResultsPage.tsx

Comment thread src/pages/PublicReport.tsx
Comment thread src/pages/PublicReport.tsx Outdated
@jpdevhub

Copy link
Copy Markdown
Owner

Their are merge conflicts resolve that carefully

@saitejasviputta

saitejasviputta commented Jun 29, 2026

Copy link
Copy Markdown
Author

@jpdevhub, Thanks for the feedback! I've fixed the CI issues. The PR is ready for another review. Please let me know if any other changes are needed.

@jpdevhub

jpdevhub commented Jul 2, 2026

Copy link
Copy Markdown
Owner

Hey @saitejasviputta, thanks for updating the PR!

The logic looks good, but there's a critical issue that breaks the build. Could you fix these before we merge?

  1. Build Failure in PublicReport.tsx You completely removed the handleShare function definition at the top, but left the onClick={handleShare} button inside the JSX (around line 127). This will cause a TypeScript ReferenceError and the build will fail. Since you added the new copy button above, you should probably remove the old "SHARE" button entirely.

  2. Duplicate imports in ResultsPage.tsx You added import { ArrowRight, Copy } from 'lucide-react'; at the top, but left the original import { ArrowRight } from 'lucide-react'; a few lines below. Please remove the duplicate to keep the code clean.

Once these two things are fixed, I'll go ahead and merge!

@saitejasviputta

Copy link
Copy Markdown
Author

Hello @jpdevhub ,
Thanks for the review! I've addressed the requested changes:

  • Removed the obsolete Copy Share Link button and kept the new copy icon for the public report URL.
  • Cleaned up the duplicate/leftover code from the merge conflict.
  • Verified everything locally with npm run lint and npm run build, and both pass successfully.

The latest changes have been pushed. Please let me know if there's anything else that needs to be adjusted.
Thank you!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
src/pages/PublicReport.tsx (3)

33-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated clipboard-copy-with-toast pattern across files.

copyReportUrl here duplicates the try/catch/toast structure of copyScanId in src/pages/ResultsPage.tsx, and a third variant in src/pages/ScannerPage.tsx uses yet another pattern (boolean copied state, no toast). Consider extracting a shared copyToClipboard(text, successMessage, errorMessage) helper/hook to keep behavior consistent and reduce future drift.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/PublicReport.tsx` around lines 33 - 44, The clipboard-copy flow in
copyReportUrl duplicates the same try/catch/toast pattern used by copyScanId and
diverges from ScannerPage, so extract a shared copyToClipboard helper or hook
and use it here instead. Move the clipboard write plus success/error toast
handling into the shared utility, then have PublicReport’s copyReportUrl call
that helper with the report URL and its success/error messages so all three
pages behave consistently.

37-44: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

New copy-to-clipboard strings bypass i18n.

Every other user-facing string in this file was converted to t(...) (headings, terminal messages, button label), but the new "PUBLIC REPORT URL" heading, aria-label/title="Copy Public Report URL", and the toast messages ('Public report URL copied!', 'Failed to copy public report URL.') remain hardcoded English. This leaves non-English users with a mixed-language UI.

💬 Proposed fix
   const copyReportUrl = async () => {
   try {
     await navigator.clipboard.writeText(reportUrl);
-    toast.success('Public report URL copied!');
+    toast.success(t('publicReport.urlCopied'));
   } catch {
-    toast.error('Failed to copy public report URL.');
+    toast.error(t('publicReport.urlCopyFailed'));
   }
 };
@@
           <p className="font-mono text-[0.65rem] tracking-widest text-on-surface-variant mb-2 uppercase">
-            PUBLIC REPORT URL
+            {t('publicReport.reportUrlLabel')}
             </p>
@@
               <button
               type="button"
               onClick={copyReportUrl}
-              aria-label="Copy public report URL"
-              title="Copy Public Report URL"
+              aria-label={t('publicReport.copyUrlAria')}
+              title={t('publicReport.copyUrlTitle')}
               className="shrink-0 ml-3 text-on-surface-variant hover:text-neon"
              >

Also applies to: 101-121

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/PublicReport.tsx` around lines 37 - 44, The new copy-to-clipboard
UI strings in PublicReport are still hardcoded English, so update the heading,
copy button aria-label/title, and both toast messages to use the existing i18n
pattern with t(...). Use the same translation approach already used elsewhere in
PublicReport.tsx and keep the string keys consistent around the copyReportUrl
handler and the “PUBLIC REPORT URL” section so all user-facing text is
localized.

1-135: 📐 Maintainability & Code Quality | 🔵 Trivial

PR complexity label: complexity: basic.

This change adds a contained clipboard-copy UI control (icon, handler, toast) to an existing page without introducing new endpoints, state machines, or architectural changes — fits "small UI tweaks, simple bug fixes."

As per path instructions, "Analyze the code changes and the PR description... automatically apply ONE of the following labels to the PR."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/PublicReport.tsx` around lines 1 - 135, The PR description says
this change should automatically apply a single complexity label, but the
current `PublicReport` update only adds the clipboard UI and does not reflect
any labeling behavior. Update the PR/labeling logic associated with this change
so it assigns the correct one label (`complexity: basic`) based on the described
scope, and verify the label selection flow uses the existing review/analysis
output rather than hardcoding page UI details.

Source: Path instructions

src/pages/ResultsPage.tsx (1)

76-83: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Toast copy strings bypass i18n.

The rest of this file's user-facing strings are translated via t(...), but 'Scan ID copied to clipboard!' and 'Failed to copy Scan ID.' are hardcoded English, breaking localization consistency.

💬 Proposed fix
   const copyScanId = async (scanId: string) => {
   try {
     await navigator.clipboard.writeText(scanId);
-    toast.success('Scan ID copied to clipboard!');
+    toast.success(t('results.scanIdCopied'));
   } catch {
-    toast.error('Failed to copy Scan ID.');
+    toast.error(t('results.scanIdCopyFailed'));
   }
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/ResultsPage.tsx` around lines 76 - 83, The copyScanId helper in
ResultsPage uses hardcoded toast text, bypassing the file’s i18n pattern.
Replace the success and error strings in copyScanId with t(...) lookups matching
the other user-facing messages in ResultsPage, and ensure the translation keys
are added/used consistently so the clipboard toasts are localized.
♻️ Duplicate comments (1)
src/pages/ResultsPage.tsx (1)

142-186: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Copy button still triggers card navigation — previous fix incomplete.

The Copy button is nested inside the card's <Link to={\/analysis?id=${h.id}`}>(opened at line 142). TheonClickhandler at line 179 only callscopyScanId; it never calls preventDefault()/stopPropagation(), so the click still bubbles to the anchor and navigates to /analysisinstead of (or alongside) copying. This was previously flagged and is only half-fixed — wrapping in a realwas done, but the event handling was not. Nesting ainside an` is also invalid HTML.

🐛 Proposed fix
                        <button
                          type="button"
-                         onClick={() => copyScanId(h.scan_display_id)}
-                        aria-label="Copy Scan ID"
+                         onClick={(event) => {
+                           event.preventDefault();
+                           event.stopPropagation();
+                           void copyScanId(h.scan_display_id);
+                         }}
+                        aria-label={`Copy scan ID ${h.scan_display_id}`}
                         title="Copy Scan ID"
                         className="shrink-0 ml-2 text-on-surface-variant hover:text-neon"
                        >
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/ResultsPage.tsx` around lines 142 - 186, The Copy button inside the
ResultsPage card Link still bubbles to the surrounding navigation, so clicking
it can trigger /analysis instead of only copying the scan ID. Update the Copy
button handler in ResultsPage so it prevents the parent Link navigation by
calling preventDefault and stopPropagation before copyScanId, and avoid keeping
an interactive button nested inside the Link by restructuring the card actions
if needed.

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/ResultsPage.tsx`:
- Around line 63-66: The retry button in ResultsPage currently relies on the
default button type, which can accidentally act as a submit button inside a
form. Update the button in ResultsPage to explicitly set type="button" while
keeping the existing onClick reload behavior and styling, so it only triggers
the page refresh action.

---

Outside diff comments:
In `@src/pages/PublicReport.tsx`:
- Around line 33-44: The clipboard-copy flow in copyReportUrl duplicates the
same try/catch/toast pattern used by copyScanId and diverges from ScannerPage,
so extract a shared copyToClipboard helper or hook and use it here instead. Move
the clipboard write plus success/error toast handling into the shared utility,
then have PublicReport’s copyReportUrl call that helper with the report URL and
its success/error messages so all three pages behave consistently.
- Around line 37-44: The new copy-to-clipboard UI strings in PublicReport are
still hardcoded English, so update the heading, copy button aria-label/title,
and both toast messages to use the existing i18n pattern with t(...). Use the
same translation approach already used elsewhere in PublicReport.tsx and keep
the string keys consistent around the copyReportUrl handler and the “PUBLIC
REPORT URL” section so all user-facing text is localized.
- Around line 1-135: The PR description says this change should automatically
apply a single complexity label, but the current `PublicReport` update only adds
the clipboard UI and does not reflect any labeling behavior. Update the
PR/labeling logic associated with this change so it assigns the correct one
label (`complexity: basic`) based on the described scope, and verify the label
selection flow uses the existing review/analysis output rather than hardcoding
page UI details.

In `@src/pages/ResultsPage.tsx`:
- Around line 76-83: The copyScanId helper in ResultsPage uses hardcoded toast
text, bypassing the file’s i18n pattern. Replace the success and error strings
in copyScanId with t(...) lookups matching the other user-facing messages in
ResultsPage, and ensure the translation keys are added/used consistently so the
clipboard toasts are localized.

---

Duplicate comments:
In `@src/pages/ResultsPage.tsx`:
- Around line 142-186: The Copy button inside the ResultsPage card Link still
bubbles to the surrounding navigation, so clicking it can trigger /analysis
instead of only copying the scan ID. Update the Copy button handler in
ResultsPage so it prevents the parent Link navigation by calling preventDefault
and stopPropagation before copyScanId, and avoid keeping an interactive button
nested inside the Link by restructuring the card actions if needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5b815e8b-8dcc-4b2b-b0a8-b92c10867c06

📥 Commits

Reviewing files that changed from the base of the PR and between bdd2b88 and 4c980e9.

📒 Files selected for processing (2)
  • src/pages/PublicReport.tsx
  • src/pages/ResultsPage.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
src/pages/PublicReport.tsx (3)

33-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated clipboard-copy-with-toast pattern across files.

copyReportUrl here duplicates the try/catch/toast structure of copyScanId in src/pages/ResultsPage.tsx, and a third variant in src/pages/ScannerPage.tsx uses yet another pattern (boolean copied state, no toast). Consider extracting a shared copyToClipboard(text, successMessage, errorMessage) helper/hook to keep behavior consistent and reduce future drift.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/PublicReport.tsx` around lines 33 - 44, The clipboard-copy flow in
copyReportUrl duplicates the same try/catch/toast pattern used by copyScanId and
diverges from ScannerPage, so extract a shared copyToClipboard helper or hook
and use it here instead. Move the clipboard write plus success/error toast
handling into the shared utility, then have PublicReport’s copyReportUrl call
that helper with the report URL and its success/error messages so all three
pages behave consistently.

37-44: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

New copy-to-clipboard strings bypass i18n.

Every other user-facing string in this file was converted to t(...) (headings, terminal messages, button label), but the new "PUBLIC REPORT URL" heading, aria-label/title="Copy Public Report URL", and the toast messages ('Public report URL copied!', 'Failed to copy public report URL.') remain hardcoded English. This leaves non-English users with a mixed-language UI.

💬 Proposed fix
   const copyReportUrl = async () => {
   try {
     await navigator.clipboard.writeText(reportUrl);
-    toast.success('Public report URL copied!');
+    toast.success(t('publicReport.urlCopied'));
   } catch {
-    toast.error('Failed to copy public report URL.');
+    toast.error(t('publicReport.urlCopyFailed'));
   }
 };
@@
           <p className="font-mono text-[0.65rem] tracking-widest text-on-surface-variant mb-2 uppercase">
-            PUBLIC REPORT URL
+            {t('publicReport.reportUrlLabel')}
             </p>
@@
               <button
               type="button"
               onClick={copyReportUrl}
-              aria-label="Copy public report URL"
-              title="Copy Public Report URL"
+              aria-label={t('publicReport.copyUrlAria')}
+              title={t('publicReport.copyUrlTitle')}
               className="shrink-0 ml-3 text-on-surface-variant hover:text-neon"
              >

Also applies to: 101-121

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/PublicReport.tsx` around lines 37 - 44, The new copy-to-clipboard
UI strings in PublicReport are still hardcoded English, so update the heading,
copy button aria-label/title, and both toast messages to use the existing i18n
pattern with t(...). Use the same translation approach already used elsewhere in
PublicReport.tsx and keep the string keys consistent around the copyReportUrl
handler and the “PUBLIC REPORT URL” section so all user-facing text is
localized.

1-135: 📐 Maintainability & Code Quality | 🔵 Trivial

PR complexity label: complexity: basic.

This change adds a contained clipboard-copy UI control (icon, handler, toast) to an existing page without introducing new endpoints, state machines, or architectural changes — fits "small UI tweaks, simple bug fixes."

As per path instructions, "Analyze the code changes and the PR description... automatically apply ONE of the following labels to the PR."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/PublicReport.tsx` around lines 1 - 135, The PR description says
this change should automatically apply a single complexity label, but the
current `PublicReport` update only adds the clipboard UI and does not reflect
any labeling behavior. Update the PR/labeling logic associated with this change
so it assigns the correct one label (`complexity: basic`) based on the described
scope, and verify the label selection flow uses the existing review/analysis
output rather than hardcoding page UI details.

Source: Path instructions

src/pages/ResultsPage.tsx (1)

76-83: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Toast copy strings bypass i18n.

The rest of this file's user-facing strings are translated via t(...), but 'Scan ID copied to clipboard!' and 'Failed to copy Scan ID.' are hardcoded English, breaking localization consistency.

💬 Proposed fix
   const copyScanId = async (scanId: string) => {
   try {
     await navigator.clipboard.writeText(scanId);
-    toast.success('Scan ID copied to clipboard!');
+    toast.success(t('results.scanIdCopied'));
   } catch {
-    toast.error('Failed to copy Scan ID.');
+    toast.error(t('results.scanIdCopyFailed'));
   }
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/ResultsPage.tsx` around lines 76 - 83, The copyScanId helper in
ResultsPage uses hardcoded toast text, bypassing the file’s i18n pattern.
Replace the success and error strings in copyScanId with t(...) lookups matching
the other user-facing messages in ResultsPage, and ensure the translation keys
are added/used consistently so the clipboard toasts are localized.
♻️ Duplicate comments (1)
src/pages/ResultsPage.tsx (1)

142-186: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Copy button still triggers card navigation — previous fix incomplete.

The Copy button is nested inside the card's <Link to={\/analysis?id=${h.id}`}>(opened at line 142). TheonClickhandler at line 179 only callscopyScanId; it never calls preventDefault()/stopPropagation(), so the click still bubbles to the anchor and navigates to /analysisinstead of (or alongside) copying. This was previously flagged and is only half-fixed — wrapping in a realwas done, but the event handling was not. Nesting ainside an` is also invalid HTML.

🐛 Proposed fix
                        <button
                          type="button"
-                         onClick={() => copyScanId(h.scan_display_id)}
-                        aria-label="Copy Scan ID"
+                         onClick={(event) => {
+                           event.preventDefault();
+                           event.stopPropagation();
+                           void copyScanId(h.scan_display_id);
+                         }}
+                        aria-label={`Copy scan ID ${h.scan_display_id}`}
                         title="Copy Scan ID"
                         className="shrink-0 ml-2 text-on-surface-variant hover:text-neon"
                        >
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/ResultsPage.tsx` around lines 142 - 186, The Copy button inside the
ResultsPage card Link still bubbles to the surrounding navigation, so clicking
it can trigger /analysis instead of only copying the scan ID. Update the Copy
button handler in ResultsPage so it prevents the parent Link navigation by
calling preventDefault and stopPropagation before copyScanId, and avoid keeping
an interactive button nested inside the Link by restructuring the card actions
if needed.

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/ResultsPage.tsx`:
- Around line 63-66: The retry button in ResultsPage currently relies on the
default button type, which can accidentally act as a submit button inside a
form. Update the button in ResultsPage to explicitly set type="button" while
keeping the existing onClick reload behavior and styling, so it only triggers
the page refresh action.

---

Outside diff comments:
In `@src/pages/PublicReport.tsx`:
- Around line 33-44: The clipboard-copy flow in copyReportUrl duplicates the
same try/catch/toast pattern used by copyScanId and diverges from ScannerPage,
so extract a shared copyToClipboard helper or hook and use it here instead. Move
the clipboard write plus success/error toast handling into the shared utility,
then have PublicReport’s copyReportUrl call that helper with the report URL and
its success/error messages so all three pages behave consistently.
- Around line 37-44: The new copy-to-clipboard UI strings in PublicReport are
still hardcoded English, so update the heading, copy button aria-label/title,
and both toast messages to use the existing i18n pattern with t(...). Use the
same translation approach already used elsewhere in PublicReport.tsx and keep
the string keys consistent around the copyReportUrl handler and the “PUBLIC
REPORT URL” section so all user-facing text is localized.
- Around line 1-135: The PR description says this change should automatically
apply a single complexity label, but the current `PublicReport` update only adds
the clipboard UI and does not reflect any labeling behavior. Update the
PR/labeling logic associated with this change so it assigns the correct one
label (`complexity: basic`) based on the described scope, and verify the label
selection flow uses the existing review/analysis output rather than hardcoding
page UI details.

In `@src/pages/ResultsPage.tsx`:
- Around line 76-83: The copyScanId helper in ResultsPage uses hardcoded toast
text, bypassing the file’s i18n pattern. Replace the success and error strings
in copyScanId with t(...) lookups matching the other user-facing messages in
ResultsPage, and ensure the translation keys are added/used consistently so the
clipboard toasts are localized.

---

Duplicate comments:
In `@src/pages/ResultsPage.tsx`:
- Around line 142-186: The Copy button inside the ResultsPage card Link still
bubbles to the surrounding navigation, so clicking it can trigger /analysis
instead of only copying the scan ID. Update the Copy button handler in
ResultsPage so it prevents the parent Link navigation by calling preventDefault
and stopPropagation before copyScanId, and avoid keeping an interactive button
nested inside the Link by restructuring the card actions if needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5b815e8b-8dcc-4b2b-b0a8-b92c10867c06

📥 Commits

Reviewing files that changed from the base of the PR and between bdd2b88 and 4c980e9.

📒 Files selected for processing (2)
  • src/pages/PublicReport.tsx
  • src/pages/ResultsPage.tsx
🛑 Comments failed to post (1)
src/pages/ResultsPage.tsx (1)

63-66: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Add explicit type="button".

Flagged by static analysis: a <button> with no type defaults to submit, which can accidentally submit an enclosing form.

🔧 Proposed fix
           <button
+            type="button"
             onClick={() => window.location.reload()}
             className="text-neon font-[family-name:var(--font-mono)] text-xs tracking-widest no-underline hover:underline bg-transparent border-none cursor-pointer"
           >{t('common.tryAgain')}</button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

          <button
            type="button"
            onClick={() => window.location.reload()}
            className="text-neon font-[family-name:var(--font-mono)] text-xs tracking-widest no-underline hover:underline bg-transparent border-none cursor-pointer"
          >{t('common.tryAgain')}</button>
🧰 Tools
🪛 React Doctor (0.5.8)

[warning] 63-63: Your users can submit the form by accident because a <button> with no type defaults to submit.

Set an explicit button type so plain buttons do not submit forms by accident: type="button", "submit", or "reset".

(button-has-type)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/ResultsPage.tsx` around lines 63 - 66, The retry button in
ResultsPage currently relies on the default button type, which can accidentally
act as a submit button inside a form. Update the button in ResultsPage to
explicitly set type="button" while keeping the existing onClick reload behavior
and styling, so it only triggers the page refresh action.

Source: Linters/SAST tools

@saitejasviputta

Copy link
Copy Markdown
Author

Hello @jpdevhub ,
Thanks for the review! I've addressed the requested changes:

Removed the obsolete Copy Share Link button and kept the new copy icon for the public report URL.
Cleaned up the duplicate/leftover code from the merge conflict.
Verified everything locally with npm run lint and npm run build, and both pass successfully.
The latest changes have been pushed. Please let me know if there's anything else that needs to be adjusted.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Copy to Clipboard for Scan Display ID & Report URL

2 participants